package com.excellence.service.impl;

import com.excellence.mapper.CommentMapper;
import com.excellence.pojo.Comment;
import com.excellence.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName CommentServiceImpl
 * @Description TODO
 * @date 2024/4/8 10:49
 * @Version 1.0
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentMapper commentMapper;

    @Override
    public int deleteByKey(Long id) {
        Comment record = commentMapper.selectByPrimaryKey(id);
        record.setDeleted(1);
        return commentMapper.updateByPrimaryKey(record);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return commentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Comment record) {
        record.setCreateTime(new Date());
        return commentMapper.insert(record);
    }

    @Override
    public int insertSelective(Comment record) {
        record.setCreateTime(new Date());
        return commentMapper.insertSelective(record);
    }

    @Override
    public Comment selectByPrimaryKey(Long id) {
        return commentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Comment> selectAll() {
        return commentMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKeySelective(Comment record) {
        return commentMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Comment record) {
        return commentMapper.updateByPrimaryKey(record);
    }
}
